package com.xinling.modules.blog.service.impl;

import com.xinling.modules.blog.mapper.BlogCategoryMapper;
import com.xinling.modules.blog.model.entity.BlogCategory;
import com.xinling.modules.blog.service.BlogCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class BlogCategoryServiceImpl implements BlogCategoryService {

    @Autowired
    private BlogCategoryMapper categoryMapper;

    @Override
    public List<BlogCategory> findAll() {
        return categoryMapper.selectAll();
    }

    @Override
    public BlogCategory findById(Integer id) {
        return categoryMapper.selectById(id);
    }

    @Override
    @Transactional
    public BlogCategory create(BlogCategory category) {
        categoryMapper.insert(category);
        return category;
    }

    @Override
    @Transactional
    public BlogCategory update(BlogCategory category) {
        categoryMapper.updateById(category);
        return category;
    }

    @Override
    @Transactional
    public void delete(Integer id) {
        categoryMapper.deleteById(id);
    }
} 